﻿package core.ui
{
    import core.ui.controls.*;
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;

    public class Splash extends Sprite
    {
        var ed:Tuyitu;
        private var closeme:IconButton;
        private var cni:OpenImageButton;
        private var ofc:OpenImageButton;
        private var ofl:OpenImageButton;
        private var ofu:OpenImageButton;

        public function Splash(param1:Tuyitu, param2:String = "", param3:Boolean = false)
        {
            var _loc_4:Bitmap = null;
            this.ed = param1;
            this.filters = [new DropShadowFilter(2, 45, 0, 0.3, 5, 5, 1, 2)];
            param1.addChild(this);
            param1.SetModal(this, true);
            this.DrawBox(this.graphics, 400, U.IsParamTrue("locktarget") ? (332) : (400));
            var _loc_5:* = new Bitmap(new SplashHeader());
            _loc_5.x = 15;
            _loc_5.y = 15;
            addChild(_loc_5);
            this.closeme = new IconButton(param1, "rm_close", new SplashClose());
            this.closeme.addEventListener(MouseEvent.CLICK, this.DoTask, false, 1, true);
            this.closeme.y = 8;
            this.closeme.x = 376;
            addChild(this.closeme);
            this.cni = new OpenImageButton(new NewImageIcon(), "rm_create_new_image", "rm_create_new_image_desc", -1);
            this.cni.addEventListener(MouseEvent.CLICK, this.DoTask, false, 0, true);
            this.cni.x = 15;
            this.cni.y = 121;
            addChild(this.cni);
            this.ofc = new OpenImageButton(new OpenImageIcon(), "rm_open_image_from_computer", "rm_open_image_from_computer_desc");
            this.ofc.addEventListener(MouseEvent.CLICK, this.DoTask, false, 0, true);
            this.ofc.x = 15;
            this.ofc.y = 189;
            addChild(this.ofc);
            this.ofu = new OpenImageButton(new UrlImageIcon(), "rm_open_image_from_url", "rm_open_image_from_url_desc");
            this.ofu.addEventListener(MouseEvent.CLICK, this.DoTask, false, 0, true);
            this.ofu.x = 15;
            this.ofu.y = 257;
            addChild(this.ofu);
            if (!U.IsParamTrue("locktarget"))
            {
                this.ofl = new OpenImageButton(new LibraryImageIcon(), "rm_open_image_from_library", "rm_open_image_from_library_desc");
                this.ofl.addEventListener(MouseEvent.CLICK, this.DoTask, false, 0, true);
                this.ofl.x = 15;
                this.ofl.y = 325;
                addChild(this.ofl);
                _loc_4 = new Bitmap(new SocialIcon());
                _loc_4.x = 338;
                _loc_4.y = 368;
                addChild(_loc_4);
            }
            this.Center();
            return;
        }// end function

        public function DrawBox(rm_create_new_image:Graphics, rm_create_new_image:int, rm_create_new_image:int) : void
        {
            rm_create_new_image.beginFill(0);
            rm_create_new_image.drawRect(0, 0, rm_create_new_image, rm_create_new_image);
            rm_create_new_image.beginFill(4868682);
            rm_create_new_image.drawRect(1, 1, rm_create_new_image - 2, rm_create_new_image - 2);
            rm_create_new_image.beginFill(2500134);
            rm_create_new_image.drawRect(2, 2, rm_create_new_image - 4, rm_create_new_image - 4);
            rm_create_new_image.beginFill(15724527);
            rm_create_new_image.drawRect(5, 5, rm_create_new_image - 10, rm_create_new_image - 10);
            rm_create_new_image.endFill();
            return;
        }// end function

        public function Center() : void
        {
            this.x = int(stage.stageWidth / 2) - 200;
            this.y = int(stage.stageHeight / 2) - 225;
            return;
        }// end function

        private function DoTask(event:MouseEvent) : void
        {
            this.ed.removeChild(this);
            this.ed.RemoveModal();
            this.ed.splash = null;
            switch(event.currentTarget)
            {
                case this.cni:
                {
                    this.ed.cm.NewImage();
                    break;
                }
                case this.ofc:
                {
                    this.ed.cm.OpenImage();
                    break;
                }
                case this.ofu:
                {
                    this.ed.cm.OpenImageFrom();
                    break;
                }
                case this.ofl:
                {
                    this.ed.cm.OpenImageLibrary();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
